home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / modelers / geomview / source.lha / Geomview / src / bin / hinge / lang.c < prev    next >
C/C++ Source or Header  |  1992-11-16  |  2KB  |  114 lines

  1. #include <stdio.h>
  2. #include <math.h>
  3. #include "3d.h"
  4. #include "hinge.h"
  5. #include "hui.h"
  6. #include "lang.h"
  7. #include "ooglutil.h"
  8. #include "pickfunc.h"
  9.  
  10. static Lake *inlake;
  11.  
  12. DEFPICKFUNC("(pick COORDSYS GEOMID G V E F P VI EI FI)",
  13.         coordsys,
  14.         id,
  15.         point, pn,
  16.         vertex, vn,
  17.         edge, en,
  18.         face, fn, 10,
  19.         ppath, ppn, 50,
  20.         vi,
  21.         ei, ein,
  22.         fi,
  23. {
  24.   handle_pick(id, &point, vn>0, &vertex, en>0, edge);
  25.   return Lt;
  26. })
  27.  
  28. #if 0
  29. LObject *Lpicked(Lake *lake, LList *args)
  30. /* (picked name (gotx goty gotz) (vx vy vz) (e0x e0y e0z e1z e1y e1z))
  31.    all arguments are optional;  v and e lists may be empty */
  32. {
  33.   LObject *arg;
  34.   char *name = NULL;
  35.   Point3 g,v,e[2];
  36.   int gn=3, vn=3, en=6, picked;
  37.  
  38.   LDECLARE(("picked", lake, args,
  39.         LARG_OPTIONAL,
  40.         LARG_STRING, &name,
  41.         LARG_HOLD, LARG_FLOAT_ARRAY, &g, &gn,
  42.         LARG_HOLD, LARG_FLOAT_ARRAY, &v, &vn,
  43.         LARG_HOLD, LARG_FLOAT_ARRAY, e, &en,
  44.         LARG_END));
  45.  
  46.   handle_pick(name, &g, vn>0, &v, en>0, e);
  47.   return Lt;
  48. }
  49. #endif
  50.  
  51. void
  52. handle_pick(char *name, HPoint3 *got,
  53.         int vert, HPoint3 *v, int edge, HPoint3 e[])
  54. {
  55.   int n;
  56.   
  57.   if (name) {
  58.     if (sscanf(name, "geom%d", &n) != 1) return;
  59.     TmCopy(TT[n], BaseT);
  60.     if (edge) {
  61.       DefineAxis(&e[0], &e[1]);
  62.     }
  63.     ShowAxis();
  64.   }
  65.   
  66.   if (haveaxis) {
  67.     int faceno, edgetest;
  68.     char buf[80];
  69.     
  70.     
  71.     faceno = -1;
  72.     if (!edge && !vert) {
  73.       faceno = WhichFace(got, *(TT[n]), pl);
  74.       if (faceno >= 0) {
  75.     edgetest = PolyContainsEdge( currentedge,
  76.                     *(TT[n]), &(pl->p[faceno]) );
  77.     if (edgetest) {
  78.       TmCopy(TT[n], BaseT);
  79.       HingeIt(edgetest);
  80.     }
  81.       }
  82.       
  83.     }
  84.     
  85.     if (faceno >= 0) {
  86.       sprintf(buf, "face %1d of geom %1d; edgetest->%1d\n",
  87.           faceno, n, edgetest);
  88.     } else {
  89.       sprintf(buf, "no face\n");
  90.     }
  91.     hui_message(buf);
  92.   }
  93. }
  94.  
  95.  
  96. LangInit()
  97. {
  98.   inlake = LakeDefine(stdin, stdout, NULL);
  99.  
  100.   LInit();
  101.   LDefun("pick",  Lpick, Hpick);
  102. }
  103.  
  104.  
  105. void
  106. Input()
  107. {
  108.   LObject *lit, *val;
  109.   lit = LSexpr(inlake);
  110.   val = LEval(lit);
  111.   LFree(lit);
  112.   LFree(val);
  113. }
  114.